package myactionplugin;

public class ToJavaUtils {

	public static String[] changeJava(String a){
		
		String a1 = a.replace("exception" , "class");
		String a2 = a1.replace("message" , "class");
		String a3 = a2.replace("local class" , "class");
		String a4 = a3.replace("enumeration" , "enum");
		String a5 = a4.replace("string" , "String");

		String[] list = a5.split("}\r\n");
		return list;
		
	}
	
	/**
	 * 截取包名
	 * @param a
	 * @return
	 */
	public static String getPackage(String a){
		
		int beginIndex = a.indexOf("Package ")+"Package ".length();
		int endIndex = a.indexOf("{");
		return a.substring(beginIndex, endIndex);
		
	}
	
	public static String getMainString(String a){
		
		int beginIndex = a.indexOf("{\r\n")+"{\r\n".length();
		if(a.indexOf("}")<0){
			return a.substring(beginIndex,a.length());
		}else{
			int endIndex = a.lastIndexOf("}");
			return a.substring(beginIndex, endIndex);
		}
		
		
	}
	
	public static String getClassName(String a){
		
		int start = a.indexOf(" ",3)+1;
		int end = a.indexOf("{");
		return a.substring(start, end);
		
	} 
	
	/**
	 * 获取类的类型
	 * @param a
	 * @return
	 */
	public static String getClassType(String a){
		
		int start = 0;
		int end = a.indexOf(" ");
		return a.substring(start, end);
		
	}
	
	
}
